package com.jianbing.shasha.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jianbing.common.annotation.Log;
import com.jianbing.common.core.controller.BaseController;
import com.jianbing.common.core.domain.AjaxResult;
import com.jianbing.common.enums.BusinessType;
import com.jianbing.shasha.domain.ShashaReward;
import com.jianbing.shasha.service.IShashaRewardService;
import com.jianbing.common.utils.poi.ExcelUtil;
import com.jianbing.common.core.page.TableDataInfo;

/**
 * 用户能够获得奖励记录Controller
 * 
 * @author ruoyi
 * @date 2024-06-09
 */
@RestController
@RequestMapping("/shasha/reward")
public class ShashaRewardController extends BaseController
{
    @Autowired
    private IShashaRewardService shashaRewardService;

    /**
     * 查询用户能够获得奖励记录列表
     */
    // @PreAuthorize("@ss.hasPermi('shasha:reward:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShashaReward shashaReward)
    {
        startPage();
        List<ShashaReward> list = shashaRewardService.selectShashaRewardList(shashaReward);
        return getDataTable(list);
    }

    /**
     * 导出用户能够获得奖励记录列表
     */
    //  @PreAuthorize("@ss.hasPermi('shasha:reward:export')")
    @Log(title = "用户能够获得奖励记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShashaReward shashaReward)
    {
        List<ShashaReward> list = shashaRewardService.selectShashaRewardList(shashaReward);
        ExcelUtil<ShashaReward> util = new ExcelUtil<ShashaReward>(ShashaReward.class);
        util.exportExcel(response, list, "用户能够获得奖励记录数据");
    }

    /**
     * 获取用户能够获得奖励记录详细信息
     */
    //  @PreAuthorize("@ss.hasPermi('shasha:reward:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(shashaRewardService.selectShashaRewardById(id));
    }

    /**
     * 新增用户能够获得奖励记录
     */
    // @PreAuthorize("@ss.hasPermi('shasha:reward:add')")
    @Log(title = "用户能够获得奖励记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShashaReward shashaReward)
    {
        return toAjax(shashaRewardService.insertShashaReward(shashaReward));
    }

    /**
     * 修改用户能够获得奖励记录
     */
    // @PreAuthorize("@ss.hasPermi('shasha:reward:edit')")
    @Log(title = "用户能够获得奖励记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShashaReward shashaReward)
    {
        return toAjax(shashaRewardService.updateShashaReward(shashaReward));
    }

    /**
     * 删除用户能够获得奖励记录
     */
    //  @PreAuthorize("@ss.hasPermi('shasha:reward:remove')")
    @Log(title = "用户能够获得奖励记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(shashaRewardService.deleteShashaRewardByIds(ids));
    }
}
